package com.android.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.android.view.hqview.IndexModel;


/**
 * K线数据缓存
 */
public class HqKlineDb {

    private SharedPreferences mSharedPreferences;
    private Context context;
    private SharedPreferences.Editor et;

    public HqKlineDb(Context context) {
        mSharedPreferences = context.getSharedPreferences("hqIndexSetting", Context.MODE_PRIVATE);
        et = mSharedPreferences.edit();
    }
    public void setClearIndex(){
        et.putString("topIndex", IndexModel.MAJUST);
        et.putString("bottomIndex", IndexModel.IX_VOL);
        et.commit();
    }
    public int getTabIndex(){
        return  mSharedPreferences.getInt("tabIndex",0);
    }
    public void setTabIndex(int p){
        et.putInt("tabIndex",p);
        et.commit();
    }
    public String getTopIndex(){
        return mSharedPreferences.getString("topIndex", IndexModel.MAJUST);
    }
    public void setTopIndex(String topIndex){
        et.putString("topIndex",topIndex);
        et.commit();
    }

    public String getBottomIndex(){
        return mSharedPreferences.getString("bottomIndex", IndexModel.IX_VOL);
    }
    public void setBottomIndex(String bottomIndex){
        et.putString("bottomIndex",bottomIndex);
        et.commit();
    }

    public int getMA1() {
        return mSharedPreferences.getInt("MA1", 5);
    }

    public void setMA1(int n) {
        et.putInt("MA1", n);
        et.commit();
    }

    public int getMA2() {
        return mSharedPreferences.getInt("MA2", 10);
    }

    public void setMA2(int n) {
        et.putInt("MA2", n);
        et.commit();
    }

    public int getMA3() {
        return mSharedPreferences.getInt("MA3", 20);
    }

    public void setMA3(int n) {
        et.putInt("MA3", n);
        et.commit();
    }

    public int getBOLL1() {
        return mSharedPreferences.getInt("BOLL1", 20);
    }

    public void setBOLL1(int n) {
        et.putInt("BOLL1", n);
        et.commit();
    }

    public int getBOLL2() {
        return mSharedPreferences.getInt("BOLL2", 2);
    }

    public void setBOLL2(int n) {
        et.putInt("BOLL2", n);
        et.commit();
    }

    public int getMACD1() {
        return mSharedPreferences.getInt("MACD1", 12);
    }

    public void setMACD1(int n) {
        et.putInt("MACD1", n);
        et.commit();
    }

    public int getMACD2() {
        return mSharedPreferences.getInt("MACD2", 26);
    }

    public void setMACD2(int n) {
        et.putInt("MACD2", n);
        et.commit();
    }

    public int getMACD3() {
        return mSharedPreferences.getInt("MACD3", 9);
    }

    public void setMACD3(int n) {
        et.putInt("MACD3", n);
        et.commit();
    }


    public int getK() {
        return mSharedPreferences.getInt("K", 9);
    }

    public void setK(int n) {
        et.putInt("K", n);
        et.commit();
    }

    public int getD() {
        return mSharedPreferences.getInt("D", 3);
    }

    public void setD(int n) {
        et.putInt("D", n);
        et.commit();
    }

    public int getJ() {
        return mSharedPreferences.getInt("J", 3);
    }

    public void setJ(int n) {
        et.putInt("J", n);
        et.commit();
    }

    public int getRSI1() {
        return mSharedPreferences.getInt("RSI1", 6);
    }

    public void setRSI1(int n) {
        et.putInt("RSI1", n);
        et.commit();
    }

    public int getRSI2() {
        return mSharedPreferences.getInt("RSI2", 12);
    }

    public void setRSI2(int n) {
        et.putInt("RSI2", n);
        et.commit();
    }

    public int getRSI3() {
        return mSharedPreferences.getInt("RSI3", 24);
    }

    public void setRSI3(int n) {
        et.putInt("RSI3", n);
        et.commit();
    }


    public int getSelectAverageIndex() {
        return mSharedPreferences.getInt("averageIndex", 0);
    }

    public void setSelectAverageIndex(int index) {
        et.putInt("averageIndex", index);
        et.commit();
    }

    //默认收盘
    public int getSelectDataIndex() {
        return mSharedPreferences.getInt("selectDataIndex", 3);
    }

    public void setSelectDataIndex(int index) {
        et.putInt("selectDataIndex", index);
        et.commit();
    }

    public void setAllRestore() {
        et.putInt("MA1", 5);
        et.putInt("MA2", 10);
        et.putInt("MA3", 20);
        et.putInt("BOLL1", 20);
        et.putInt("BOLL2", 2);
        et.putInt("MACD1", 12);
        et.putInt("MACD2", 26);
        et.putInt("MACD3", 9);
        et.putInt("K", 9);
        et.putInt("D", 3);
        et.putInt("J", 3);
        et.putInt("RSI1", 6);
        et.putInt("RSI2", 12);
        et.putInt("RSI3", 24);
        et.commit();
    }
}
